
<template>
  <div id="d">
    <el-container>
      <el-header
        style="
          text-align: right;
          font-size: 12px;
          background-color: lightskyblue;
        "
      >
        <el-dropdown>
          <i class="el-icon-setting" style="margin-right: 15px"></i>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>
              <div @click="dialogFormVisibleUpdate = true">
                <i class="el-icon-user"></i>
                信息
              </div>
            </el-dropdown-item>
            <hr />
            <el-dropdown-item style="color: red">
              <div @click="tuichu()">
                <svg
                  t="1699515523342"
                  class="icon"
                  viewBox="0 0 1024 1024"
                  version="1.1"
                  xmlns="http://www.w3.org/2000/svg"
                  p-id="4421"
                  width="20"
                  height="20"
                >
                  <path
                    d="M512 896c-215.3 0-390.4-175.1-390.4-390.4 0-137.1 71-261.8 189.8-333.4 17.7-10.6 40.9-5 51.6 12.8 10.7 17.8 5.1 40.9-12.8 51.7-96.1 57.9-153.4 158.5-153.4 269 0 173.7 141.4 315.1 315.1 315.1S827 679.4 827 505.7c0-110.5-57.3-211.1-153.4-269-17.8-10.7-23.5-33.8-12.9-51.7 10.9-17.8 34-23.4 51.7-12.8 118.8 71.6 189.8 196.3 189.8 333.4C902.4 720.9 727.3 896 512 896z"
                    fill="#d81e06"
                    p-id="4422"
                  ></path>
                  <path
                    d="M512 523.9c-20.8 0-37.6-16.8-37.6-37.6V165.6c0-20.8 16.8-37.6 37.6-37.6s37.6 16.8 37.6 37.6v320.6c0.1 20.8-16.8 37.7-37.6 37.7z"
                    fill="#d81e06"
                    p-id="4423"
                  ></path>
                </svg>
                退出
              </div></el-dropdown-item
            >
          </el-dropdown-menu>
        </el-dropdown>
        <span>{{ $store.state.user.username }}</span>
      </el-header>
    </el-container>

    <el-container style="height: 1000px; border: 1px solid #eee">
      <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
        <el-menu unique-opened router :default-active="this.$router.path">
          <el-submenu index="index/gzt?menusText=工作台">
            <template slot="title">
              <div @click="gzt()">
                <i class="el-icon-menu"></i><strong>工作台</strong>
              </div>
            </template>
          </el-submenu>

          <el-submenu
            v-for="(item, index) in $store.state.menus"
            :key="index"
            :index="item.path"
          >
            <template slot="title">
              <svg
                t="1699427645066"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="5519"
                width="32"
                height="32"
              >
                <path
                  d="M512 853.504c-10.24 0-20.992-4.096-29.184-11.776l-300.544-300.544c-15.872-15.872-15.872-41.984 0-57.856l300.544-300.544c15.872-15.872 41.984-15.872 57.856 0l300.544 300.544c15.872 15.872 15.872 41.984 0 57.856l-300.544 300.544c-7.68 7.68-18.432 11.776-28.672 11.776z m0-642.048L211.456 512l300.544 300.544 300.544-300.544L512 211.456z"
                  p-id="5520"
                  fill="#8a8a8a"
                ></path>
                <path
                  d="M399.36 491.52h225.28c11.264 0 20.48 9.216 20.48 20.48s-9.216 20.48-20.48 20.48H399.36c-11.264 0-20.48-9.216-20.48-20.48s9.216-20.48 20.48-20.48z"
                  p-id="5521"
                  fill="#8a8a8a"
                ></path>
                <path
                  d="M532.48 399.36v225.28c0 11.264-9.216 20.48-20.48 20.48s-20.48-9.216-20.48-20.48V399.36c0-11.264 9.216-20.48 20.48-20.48s20.48 9.216 20.48 20.48z"
                  p-id="5522"
                  fill="#8a8a8a"
                ></path>
              </svg>
              <i></i><strong> {{ item.name }}</strong></template
            >
            <el-menu-item-group
              v-for="(item, index) in item.menus"
              :key="index"
            >
              <el-menu-item :index="item.linkurl">{{ item.name }}</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>

      <el-container>
        <el-main>
          <div id="gd">
            <el-breadcrumb separator-class="el-icon-arrow-right">
              <el-breadcrumb-item>首页</el-breadcrumb-item>
              <el-breadcrumb-item
                v-for="(item, index) in this.$store.state.menusText"
                :key="index"
                >{{ item }}</el-breadcrumb-item
              >
            </el-breadcrumb>
            <hr />
          </div>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>

    <el-dialog
      title="个人信息"
      style="text-align: left"
      :visible.sync="dialogFormVisibleUpdate"
    >
      <el-row>
        <el-col :span="12">用户名</el-col>
        <el-col :span="12">{{ $store.state.user.username }}</el-col>
      </el-row>
      <hr />
      <el-row>
        <el-col :span="12">真实姓名</el-col>
        <el-col :span="12">{{ $store.state.user.fullname }}</el-col>
      </el-row>
      <hr />
      <el-row>
        <el-col :span="12">手机号码</el-col>
        <el-col :span="12">{{ $store.state.user.telephone }}</el-col>
      </el-row>

      <hr />
      <el-row>
        <el-col :span="12">邮箱</el-col>
        <el-col :span="12">{{ $store.state.user.email }}</el-col>
      </el-row>
      <hr />
      <el-row>
        <el-col :span="12">注册日期</el-col>
        <el-col :span="12">{{ $store.state.user.createtime }}</el-col>
      </el-row>
      <hr />
      <br />
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dialogFormVisibleUpdate: false,
    };
  },
  methods: {
    gzt() {
      location.href = "http://localhost:8080/index/gzt?menusText=工作台";
    },
    loadmenu() {
      this.axios
        .get("/rear/Menu/menus", { params: { id: this.$store.state.user.id } })
        .then((res) => {
          this.$store.commit("menus", res.data);
        });
    },
    tuichu() {
      this.$confirm("退出当前登录, 是否继续?", "提示：", {
        distinguishCancelAndClose: true,
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "退出成功",
          });
          sessionStorage.removeItem("user");
          this.$router.replace("/login");
        })
        .catch((action) => {
          this.$message({
            type: "warning",
            message: action === "cancel" ? "取消操作" : "停留在当前页面",
          });
        });
    },
  },
  created() {
    this.loadmenu();
  },
};
</script>

<style scoped>
.el-header {
  background-color: #b3c0d1;
  color: #333;
  line-height: 60px;
}

.el-aside {
  color: #333;
}
#zhu {
  text-align: left;
  margin-left: 0%;
}
#d {
  height: 800px;
}
.el-link {
  margin-left: 200px;
}
</style>